package com.clouds.wms.cms;

import java.io.PrintWriter;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.clouds.wms.bean.Cmsme;
import com.clouds.wms.exception.SysException;
import com.clouds.wms.service.CmsmeService;

@Controller
@RequestMapping("/cmsme")
public class CmsmeController {

	private Log log = LogFactory.getLog(getClass());
	
	@Resource(name="cmsmeService")
	private CmsmeService cmsmeService;

	/**
	 * 列出所有的模块
	 * @param request
	 * @param response
	 * @return
	 * @throws SysException
	 */
	@RequestMapping(value = "/cmsmeList.xhtml")
	public String cmsmeList(HttpServletRequest request, HttpServletResponse response, Model model) throws SysException {
		List<Cmsme> list = cmsmeService.getAllCmsmeList();
		response.setContentType("text/xml;charset=utf-8");
		response.setHeader("Pragma", "No-cache");
		response.setDateHeader("Expires", 0);
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = null;
		try {
			out = response.getWriter();
			JSONObject datas = new JSONObject();
			// 设置总共有多少条记录
			// 设置当前页的数据
			datas.put("datas", list);
			out.print(datas.toString());
		} catch (Exception e) {
			log.error(e.getMessage());
		}
		return null;
	}

}
